package com.android.aircondition.activity;

import android.app.Activity;
import android.app.Dialog;
import android.widget.TextView;

import com.android.aircondition.R;
import com.android.aircondition.constant.AppConstant;
import com.android.aircondition.view.ExitAppDialog;
import com.android.aircondition.view.NetAlertDialog;
import com.android.aircondition.view.WelcomeNetAlertDialog;
/**
 * Especially for controlling exit application or not and something to reuse.
 * @author Arashmen
 * */
public class BaseActivity extends Activity{
	
//	private Handler mHandler = new Handler(){
//		public void handleMessage(android.os.Message msg) {
//			
//			WindowManager windowManager = getWindowManager();
//
//			Display display = windowManager.getDefaultDisplay();
//			int childWidth = display.getWidth()/5;
//	        HorizontalScrollView sc = (HorizontalScrollView)findViewById(R.id.Direction_tab_scroll);
//			
//	        sc.scrollTo(childWidth*msg.what, 0);
//			
//		};
//};
	
	/**
	 * use resource id to set the title for current activity
	 * @param activity , current activity
	 * @param resource , the title id
	 * @author Arashmen 
	 * */
	protected void setCommonTitle(Activity activity,int resource){
		TextView tv = (TextView)activity.findViewById(R.id.Common_title);
		tv.setText(resource);
	}
	
	
	/**
	 * use resource id to set the title for current activity
	 * @param activity , current activity
	 * @param resource , the title id
	 * @author Arashmen 
	 * */
	protected void setCommonLogo(Activity activity,int resource){
		TextView tv = (TextView)activity.findViewById(R.id.Common_title);
		tv.setBackgroundResource(resource);
	}

	/**
	 * use resource id to set the title for current activity
	 * @param activity , current activity
	 * @param title , String for title.
	 * @author Arashmen 
	 * */
	protected void setCommonTitle(Activity activity,String title){
		TextView tv = (TextView)activity.findViewById(R.id.Common_title);
		tv.setText(title);
	}
	
	/**
	 * dialog manager,especially for ExitAppDialog
	 * @param id , the dialog's id
	 * @author Arashmen
	 * */
    protected Dialog onCreateDialog(int id) {
        switch (id) {
            case AppConstant.EXIT:
                new ExitAppDialog(this).show();
                break;

            case AppConstant.DIALOG_NETALERT:
                new NetAlertDialog(this).show();
                break;
                
            case AppConstant.WELCOME_DIALOG_NETALERT:
                new WelcomeNetAlertDialog(this).show();
                break;
        }
        return super.onCreateDialog(id);
    }
	
}
